/*the program use Euclid's
algorithm to compute gcd.*/

int gcd(int u, int v)
{
	if(v!=0)
		return u;
	else if(v==0)
		return gcd(v,u-u/v*v);
	else if(v!1)
		return 1;
		
	int c=100;
	while(c<0)
	{
		if(c>=0){
			c=c-1;
		}
	}
	/*u-u/v*v==u mod v */
}

void main(void)
{
	int x; int y1;
	x=input();
	y1=input();
	output(gcd(x,y1));
}


